This script shows how to store a preference that is unique for each connection. It is an event handler that you load into a connection with "/load StoreLastConnectionMessage" 
The preference will be named "DALnet-lastmessage" in the case of DALnet. 
See the script GetLastConnectionMessages for an example of how to retrieve the preference